﻿ALTER TABLE [dbo].[USers]
	ADD CONSTRAINT [FK_Users_EmployeeID_Employees_ID] 
	FOREIGN KEY (EmployeeID)
	REFERENCES Employees (ID)	

go
ALTER TABLE [dbo].[USers]
	ADD CONSTRAINT [FK_Users_RoleId_Roles_ID] 
	FOREIGN KEY (RoleID)
	REFERENCES Roles (ID)	
go
--------------------------------------------------------------------------------------
ALTER TABLE [dbo].[Accesses]
	ADD CONSTRAINT [FK_Accesses_ModuleId_Modules_ID] 
	FOREIGN KEY ([ModuleId])
	REFERENCES [AppModules] (ID)	

go

ALTER TABLE [dbo].[Accesses]
	ADD CONSTRAINT [FK_Accesses_ParentId] 
	FOREIGN KEY (ParentId)
	REFERENCES [Accesses] (ID)	

go

----------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[RoleAccess]
	ADD CONSTRAINT [FK_RoleAccess_RoleId]
	FOREIGN KEY ([RoleId])
	REFERENCES Roles (ID)	

Go
ALTER TABLE [dbo].[RoleAccess]
	ADD CONSTRAINT [FK_RoleAccess_AccessId]
	FOREIGN KEY ([AccessId])
	REFERENCES Accesses (ID)	
go
--------------------------------------------------------------------------------
ALTER TABLE [dbo].[DepDesignationMapping]
	ADD CONSTRAINT [FK_Departments] 
	FOREIGN KEY ([DepartmentID]) 
	REFERENCES [dbo].[Departments] (ID) 
GO
ALTER TABLE [dbo].[DepDesignationMapping]
	ADD CONSTRAINT [FK_Designations] 
	FOREIGN KEY ([DesignationID]) 
	REFERENCES [dbo].[Designations] (ID) 
GO
------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[Specializations]
	ADD CONSTRAINT [FK_Specializations_Departments] 
	FOREIGN KEY ([DepartmentID]) 
	REFERENCES [dbo].[Departments] ([ID]) 
--------------------------------------------------------------------------
go
ALTER TABLE [dbo].[EmployeeQualifications]
	ADD CONSTRAINT [FK_EmployeeQualifications_Employees_ID] 
	FOREIGN KEY ([EmployeeId]) 
	REFERENCES [dbo].[Employees] ([ID]) 

go
--------------------------------------------------------------------------
ALTER TABLE [dbo].[EmployeeLicenses]
	ADD CONSTRAINT [FK_EmployeeLicenses_Employees_ID] 
	FOREIGN KEY ([EmployeeId]) 
	REFERENCES [dbo].[Employees] ([ID]) 

--------------------------------------------------------------------
go
ALTER TABLE [dbo].[ConsultantSpecialization]
	ADD CONSTRAINT [FK_ConsultantSpecialization_Employees_ID] 
	FOREIGN KEY ([EmpId]) 
	REFERENCES [dbo].[Employees] ([ID]) 

go

ALTER TABLE [dbo].[ConsultantSpecialization]
	ADD CONSTRAINT [FK_ConsultantSpecialization_Specialization_ID] 
	FOREIGN KEY ([SpecialisationId]) 
	REFERENCES [dbo].[Specializations]([ID]) 

------------------------------------------------------------------------
go


